<?php

namespace app\admin\controller;
use think\db;

class Data extends Base
{
    /**
     * 展示后台首页
     * @return \think\response\View
     */
    public function show_data()
    {
        //获取人数
        $user_num = db("user");

        //获取环境配置
        $db_verson = db::query("select VERSION()");
        $db_verson = $db_verson[0]["VERSION()"];
        $max_upload = @ini_get('file_uploads') ? ('允许 ' . ini_get('upload_max_filesize')) : '禁止';
        $gd_version = function_exists('gd_info') ? '支持：' . (is_array($gd = gd_info()) ? $gd['GD Version'] : '') : '不支持';
        $register_globals = @ini_get('register_globals') ? '开启' : '关闭';
        $db_size = 0;
        $result = db::query("SHOW TABLE STATUS LIKE '" . config("DB_PREFIX") . "%'");
        foreach ($result as $table) {
            $db_size += $table['Data_length'] + $table['Index_length'];
        }
        $db_size = $db_size ? size_count($db_size) : 'unknown';

        $this->assign([
            'db_verson' => $db_verson
            , 'max_upload' => $max_upload
            , 'gd_version' => $gd_version
            , 'register_globals' => $register_globals
            , 'db_size' => $db_size
        ]);
        return view();
    }
}